package com.zxjbyte.yiyi.framework.redis.manager;

import cn.hutool.extra.spring.SpringUtil;

/**
 * RedisDao工具类 - 提供RedisDao实例的单例访问
 * 用于无法使用Spring依赖注入的场景
 *
 * @Author zhangxingjia
 * @Date 2025/9/23 11:50
 * @Version: 1.0
 */
public final class RedisDaoHolder {

    private RedisDaoHolder() {
        // 防止实例化
    }

    private enum RedisDaoEnum {
        INSTANCE;

        private final RedisDao redisDao;

        RedisDaoEnum() {
            this.redisDao = SpringUtil.getBean(RedisDao.class);
            if (this.redisDao == null) {
                throw new IllegalStateException("RedisDao bean not found");
            }
        }
    }

    public static RedisDao getRedisDao() {
        return RedisDaoEnum.INSTANCE.redisDao;
    }
}
